part of 'purchase_item_dto.dart';

const kApiWebSubscriptionMonthDurationValue = 'month';
const kApiWebSubscriptionYearDurationValue = 'year';

class ApiWebSubscriptionDurationDto extends Equatable {
  const ApiWebSubscriptionDurationDto._internal({
    required this.durationString,
  });

  final String durationString;

  @override
  List<Object?> get props {
    return [
      durationString,
    ];
  }

  factory ApiWebSubscriptionDurationDto.fromString(String durationString) {
    return ApiWebSubscriptionDurationDto._internal(
      durationString: durationString,
    );
  }

  WebSubscriptionDuration toEntity() {
    return switch (durationString) {
      kApiWebSubscriptionMonthDurationValue => WebSubscriptionDuration.month,
      kApiWebSubscriptionYearDurationValue => WebSubscriptionDuration.year,
      _ => throw UnimplementedError(),
    };
  }
}
